<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: zhang
  Date: 2023/10/5
  Time: 22:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改用户信息</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }

        .updateu-body {
            position: relative;
            top: 0px;
            left: 0px;
            width: 1150px;
            height: 900px;
        }

        .update-title {
            width: 100%;
            height: 50px;
            font-size: 30px;
            text-align: center;
            line-height: 50px;
            color: #0F2027;
            font-family: "思源黑体";
            font-weight: bolder;
            margin-bottom: 20px;
        }

        .update {
            width: 700px;
            margin: 0px auto;
        }

        .update h4 {
            padding-bottom: 5px;
        }

        .error {
            width: 100%;
            height: 40px;
            text-align: center;
            line-height: 40px;
            font-family: 微软雅黑;
            font-size: 20px;
            font-weight: bolder;
            margin-top: 30px;
        }

    </style>
    <link href="//unpkg.com/layui@2.8.17/dist/css/layui.css" rel="stylesheet">
</head>
<body>
<div class="updateu-body">

    <c:if test="${requestScope.msgmap != null}">
        <c:if test="${requestScope.msgmap.get('sta') == 'yes'}">
            <div class="error" style="color: green">
                    ${requestScope.msgmap.get('msg')}
            </div>
        </c:if>
        <c:if test="${requestScope.msgmap.get('sta') == 'no'}">
            <div class="error" style="color: red">
                    ${requestScope.msgmap.get('msg')}
            </div>
        </c:if>
    </c:if>


    <div class="update-title">
        修改用户信息
    </div>

    <!-- 给容器追加 class="layui-form-pane"，即可显示为方框风格 -->
    <form class="update layui-form layui-form-pane" action="${pageContext.request.contextPath}/user/update.action"
          method="get">
        <h4>用户名</h4><input type="text" value="${sessionScope.user.uname}" name="uname" placeholder="用户名"
                           class="layui-input">

        <br>
        <h4>出生日期</h4>
        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="ubirthday" value="${sessionScope.user.ubirthday}"
                           id="ID-laydate-demo" placeholder="yyyy-MM-dd">
                </div>
            </div>
        </div>

        <h4>自我介绍</h4>
        <div class="layui-form-item layui-form-text">
            <div class="layui-input-block">
                <textarea placeholder="请输入自我介绍[算标点符号不要超过30字]" name="udesc"
                          class="layui-textarea">${sessionScope.user.udesc}</textarea>
            </div>
        </div>


        <h4>密码</h4>
        <input type="text" name="upasswd" value="${sessionScope.user.upasswd}" placeholder="密码" class="layui-input">
        <br>
        <div class="layui-form-item">
            <button type="submit" class="layui-btn" lay-submit lay-filter="demo2">确认</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            <button  class="layui-btn" onclick="deleteInfo(${sessionScope.user.uid})">注销</button>
        </div>
    </form>
</div>


<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script src="//unpkg.com/layui@2.8.17/dist/layui.js"></script>



<script>

    function deleteInfo(uid) {
        const r = confirm("确定要注销吗？");
        if (r) {
            alert("删除成功");
            window.location.href='${pageContext.request.contextPath}/user/delet.action?uid='+uid;
            return true;
        }
        return false;
    }
</script>


<script>
    layui.use(function () {
        var laydate = layui.laydate;
        // 渲染
        laydate.render({
            elem: '#ID-laydate-demo'
        });
    });
</script>
</body>
</html>
